import { http } from "@/utils/http";
import type { HttpResult } from "@/utils/http/types";

export function queryRoleTable(params) {
  return http.request<HttpResult>("get", "/admin/role/get/table", {
    params: params
  });
}

export function queryRoleList(params) {
  return http.request<HttpResult>("get", "/admin/role/get/list", {
    params: params
  });
}

export function queryRoleMenu(params) {
  return http.request<HttpResult>("get", "/admin/role/get/rolemenu?rows=0", {
    params: params
  });
}

export function queryRoleAvaliableResourceTable(params) {
  return http.request<HttpResult>("get", "/admin/role/get/resource/avaliable", {
    params: params
  });
}

export function updateRoleMenu(params) {
  return http.request<HttpResult>("post", "/admin/role/update/rolemenu", {
    data: params
  });
}

export function insertRoleResource(params) {
  return http.request<HttpResult>("post", "/admin/role/insert/resources", {
    data: params
  });
}

export function addRole(params) {
  return http.request<HttpResult>("post", "/admin/role/insert", {
    data: params
  });
}

export function updateRole(params) {
  return http.request<HttpResult>("post", "/admin/role/update", {
    data: params
  });
}

export function deleteRole(ids) {
  return http.request<HttpResult>("post", `/admin/role/delete/${ids}`);
}

export function queryValid(params) {
  return http.request<HttpResult>("get", "/admin/role/get/exists", {
    params: params
  });
}
